﻿namespace DeltaGroup.WheelOfJeopardy.UI.Commands
{
    using DeltaGroup.WheelOfJeopardy.GameManager;
    using DeltaGroup.WheelOfJeopardy.UI.Screens;
    using DeltaGroup.WheelOfJeopardy.UI.ViewModel;

    public class StartFinalJeopardyCommand : LoadUserControlCommand<FinalJeopardyScreen>
    {
        #region Methods

        /// <summary>
        /// Loads the specified window.
        /// </summary>
        /// <param name="window">The window.</param>
        /// <param name="executedRoutedEventArgs">The <see cref="System.Windows.Input.ExecutedRoutedEventArgs"/> instance containing the event data.</param>
        public override void Load(System.Windows.Window window, System.Windows.Input.ExecutedRoutedEventArgs executedRoutedEventArgs)
        {
            base.Load(window, executedRoutedEventArgs);

            UserControlInstance.DataContext = new FinalJeopardyViewModel(Game.Current.Contestants);

            var finalJeopardyRound = Game.Current.FinalJeopardy;
            finalJeopardyRound.UIManager = UserControlInstance;
            finalJeopardyRound.Finished += (sender, args) => WoJCommands.EndFinalJeopardy.Execute(null, window);
            finalJeopardyRound.Start();
        }

        #endregion Methods
    }
}